//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2022 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

@_exported import SotoCore

/// Service object for interacting with AWS AmplifyBackend service.
///
/// AWS Amplify Admin API
public struct AmplifyBackend: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the AmplifyBackend client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - timeout: Timeout value for HTTP requests
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            service: "amplifybackend",
            serviceProtocol: .restjson,
            apiVersion: "2020-08-11",
            endpoint: endpoint,
            errorType: AmplifyBackendErrorType.self,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }

    // MARK: API Calls

    /// This operation clones an existing backend.
    public func cloneBackend(_ input: CloneBackendRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<CloneBackendResponse> {
        return self.client.execute(operation: "CloneBackend", path: "/backend/{AppId}/environments/{BackendEnvironmentName}/clone", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// This operation creates a backend for an Amplify app. Backends are automatically created at the time of app creation.
    public func createBackend(_ input: CreateBackendRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<CreateBackendResponse> {
        return self.client.execute(operation: "CreateBackend", path: "/backend", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Creates a new backend API resource.
    public func createBackendAPI(_ input: CreateBackendAPIRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<CreateBackendAPIResponse> {
        return self.client.execute(operation: "CreateBackendAPI", path: "/backend/{AppId}/api", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Creates a new backend authentication resource.
    public func createBackendAuth(_ input: CreateBackendAuthRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<CreateBackendAuthResponse> {
        return self.client.execute(operation: "CreateBackendAuth", path: "/backend/{AppId}/auth", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Creates a config object for a backend.
    public func createBackendConfig(_ input: CreateBackendConfigRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<CreateBackendConfigResponse> {
        return self.client.execute(operation: "CreateBackendConfig", path: "/backend/{AppId}/config", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Creates a backend storage resource.
    public func createBackendStorage(_ input: CreateBackendStorageRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<CreateBackendStorageResponse> {
        return self.client.execute(operation: "CreateBackendStorage", path: "/backend/{AppId}/storage", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Generates a one-time challenge code to authenticate a user into your Amplify Admin UI.
    public func createToken(_ input: CreateTokenRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<CreateTokenResponse> {
        return self.client.execute(operation: "CreateToken", path: "/backend/{AppId}/challenge", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Removes an existing environment from your Amplify project.
    public func deleteBackend(_ input: DeleteBackendRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<DeleteBackendResponse> {
        return self.client.execute(operation: "DeleteBackend", path: "/backend/{AppId}/environments/{BackendEnvironmentName}/remove", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Deletes an existing backend API resource.
    public func deleteBackendAPI(_ input: DeleteBackendAPIRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<DeleteBackendAPIResponse> {
        return self.client.execute(operation: "DeleteBackendAPI", path: "/backend/{AppId}/api/{BackendEnvironmentName}/remove", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Deletes an existing backend authentication resource.
    public func deleteBackendAuth(_ input: DeleteBackendAuthRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<DeleteBackendAuthResponse> {
        return self.client.execute(operation: "DeleteBackendAuth", path: "/backend/{AppId}/auth/{BackendEnvironmentName}/remove", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Removes the specified backend storage resource.
    public func deleteBackendStorage(_ input: DeleteBackendStorageRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<DeleteBackendStorageResponse> {
        return self.client.execute(operation: "DeleteBackendStorage", path: "/backend/{AppId}/storage/{BackendEnvironmentName}/remove", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Deletes the challenge token based on the given appId and sessionId.
    public func deleteToken(_ input: DeleteTokenRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<DeleteTokenResponse> {
        return self.client.execute(operation: "DeleteToken", path: "/backend/{AppId}/challenge/{SessionId}/remove", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Generates a model schema for an existing backend API resource.
    public func generateBackendAPIModels(_ input: GenerateBackendAPIModelsRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<GenerateBackendAPIModelsResponse> {
        return self.client.execute(operation: "GenerateBackendAPIModels", path: "/backend/{AppId}/api/{BackendEnvironmentName}/generateModels", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Provides project-level details for your Amplify UI project.
    public func getBackend(_ input: GetBackendRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<GetBackendResponse> {
        return self.client.execute(operation: "GetBackend", path: "/backend/{AppId}/details", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Gets the details for a backend API.
    public func getBackendAPI(_ input: GetBackendAPIRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<GetBackendAPIResponse> {
        return self.client.execute(operation: "GetBackendAPI", path: "/backend/{AppId}/api/{BackendEnvironmentName}/details", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Generates a model schema for existing backend API resource.
    public func getBackendAPIModels(_ input: GetBackendAPIModelsRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<GetBackendAPIModelsResponse> {
        return self.client.execute(operation: "GetBackendAPIModels", path: "/backend/{AppId}/api/{BackendEnvironmentName}/getModels", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Gets a backend auth details.
    public func getBackendAuth(_ input: GetBackendAuthRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<GetBackendAuthResponse> {
        return self.client.execute(operation: "GetBackendAuth", path: "/backend/{AppId}/auth/{BackendEnvironmentName}/details", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Returns information about a specific job.
    public func getBackendJob(_ input: GetBackendJobRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<GetBackendJobResponse> {
        return self.client.execute(operation: "GetBackendJob", path: "/backend/{AppId}/job/{BackendEnvironmentName}/{JobId}", httpMethod: .GET, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Gets details for a backend storage resource.
    public func getBackendStorage(_ input: GetBackendStorageRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<GetBackendStorageResponse> {
        return self.client.execute(operation: "GetBackendStorage", path: "/backend/{AppId}/storage/{BackendEnvironmentName}/details", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Gets the challenge token based on the given appId and sessionId.
    public func getToken(_ input: GetTokenRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<GetTokenResponse> {
        return self.client.execute(operation: "GetToken", path: "/backend/{AppId}/challenge/{SessionId}", httpMethod: .GET, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Imports an existing backend authentication resource.
    public func importBackendAuth(_ input: ImportBackendAuthRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<ImportBackendAuthResponse> {
        return self.client.execute(operation: "ImportBackendAuth", path: "/backend/{AppId}/auth/{BackendEnvironmentName}/import", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Imports an existing backend storage resource.
    public func importBackendStorage(_ input: ImportBackendStorageRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<ImportBackendStorageResponse> {
        return self.client.execute(operation: "ImportBackendStorage", path: "/backend/{AppId}/storage/{BackendEnvironmentName}/import", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Lists the jobs for the backend of an Amplify app.
    public func listBackendJobs(_ input: ListBackendJobsRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<ListBackendJobsResponse> {
        return self.client.execute(operation: "ListBackendJobs", path: "/backend/{AppId}/job/{BackendEnvironmentName}", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// The list of S3 buckets in your account.
    public func listS3Buckets(_ input: ListS3BucketsRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<ListS3BucketsResponse> {
        return self.client.execute(operation: "ListS3Buckets", path: "/s3Buckets", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Removes all backend environments from your Amplify project.
    public func removeAllBackends(_ input: RemoveAllBackendsRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<RemoveAllBackendsResponse> {
        return self.client.execute(operation: "RemoveAllBackends", path: "/backend/{AppId}/remove", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Removes the AWS resources required to access the Amplify Admin UI.
    public func removeBackendConfig(_ input: RemoveBackendConfigRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<RemoveBackendConfigResponse> {
        return self.client.execute(operation: "RemoveBackendConfig", path: "/backend/{AppId}/config/remove", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Updates an existing backend API resource.
    public func updateBackendAPI(_ input: UpdateBackendAPIRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<UpdateBackendAPIResponse> {
        return self.client.execute(operation: "UpdateBackendAPI", path: "/backend/{AppId}/api/{BackendEnvironmentName}", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Updates an existing backend authentication resource.
    public func updateBackendAuth(_ input: UpdateBackendAuthRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<UpdateBackendAuthResponse> {
        return self.client.execute(operation: "UpdateBackendAuth", path: "/backend/{AppId}/auth/{BackendEnvironmentName}", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Updates the AWS resources required to access the Amplify Admin UI.
    public func updateBackendConfig(_ input: UpdateBackendConfigRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<UpdateBackendConfigResponse> {
        return self.client.execute(operation: "UpdateBackendConfig", path: "/backend/{AppId}/config/update", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Updates a specific job.
    public func updateBackendJob(_ input: UpdateBackendJobRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<UpdateBackendJobResponse> {
        return self.client.execute(operation: "UpdateBackendJob", path: "/backend/{AppId}/job/{BackendEnvironmentName}/{JobId}", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }

    /// Updates an existing backend storage resource.
    public func updateBackendStorage(_ input: UpdateBackendStorageRequest, logger: Logger = AWSClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> EventLoopFuture<UpdateBackendStorageResponse> {
        return self.client.execute(operation: "UpdateBackendStorage", path: "/backend/{AppId}/storage/{BackendEnvironmentName}", httpMethod: .POST, serviceConfig: self.config, input: input, logger: logger, on: eventLoop)
    }
}

extension AmplifyBackend {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are no public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: AmplifyBackend, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
